import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_my_app/provider/my_change_notifier_provider.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class MyChangeNotifierWiget extends ConsumerWidget {
  const MyChangeNotifierWiget({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final stateValue = ref.watch(myChangeNotifierProvider).stateValue;
    return SizedBox(
      child: Column(
        crossAxisAlignment:CrossAxisAlignment.center,
        children: [
          SizedBox(
            height: 10,
          ),
          Container(
            width: double.infinity,
            height: 30,
            alignment:Alignment.center,
            decoration: BoxDecoration(
               color: Colors.red,

            ),
            child: Text(
            ("======myChangeNotifierProvider方式测试======"),
          ),),
          SizedBox(
            height: 10,
          ),
          GestureDetector(
              onTap: () {
                ref.read(myChangeNotifierProvider).increment();
              },
              child: Center(
                child: Text(('myChangeNotifier点击修改')),
              )),
          SizedBox(
            height: 10,
          ),
          Center(
            child: Text(('myChangeNotifier value:$stateValue')),
          )
        ],
      ),
    );
  }
}
